<%@page import="java.net.URLEncoder"%>
<%@page import="java.net.URLDecoder"%>
<%@page import="java.sql.ResultSet"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="database" scope="request" class="accessibleworldsdatabase.AccessibleWorldsDatabaseJavaBeans"/>
<jsp:useBean id="des" scope="request" class="accessibleworldsdes.AccessibleWorldsDESJavaBeans"/>
<jsp:useBean id="mail" scope="request" class="accessibleworldsmail.AccessibleWorldsMailJavaBeans"/>
<%try {

String accessCode = request.getParameter("accessCode");

if(!(accessCode==null || "".equals(accessCode))) {
	
    accessCode = des.decryptString(session.getId(), accessCode);
    accessCode = URLDecoder.decode(accessCode, "UTF-8");
    
    if(des.getAndroidAccessCode().equals(accessCode) || des.getComputerAccessCode().equals(accessCode)) {

        String email = request.getParameter("email");
        
        if(!(email==null || "".equals(email))) {

            email = des.decryptString(session.getId(), email);
            email = URLDecoder.decode(email, "UTF-8");
            
            String password = "";

            database.connect(des.decryptString(des.getServiceSecretKey(), database.getEncryptedPassword()));

            String SQL =
            "SELECT * FROM Users"+
            	" WHERE"+
            		" email = \""+email+"\""+
            		" AND NOT U_type = \"0\"";
            
            ResultSet resultSet = database.execSQL(SQL);

            if(resultSet.next()) {
                password = resultSet.getString("password");
            }

            if(!("".equals(password))) {
                String message =  "Your Password = "+password;
                mail.sendMail(des.decryptString(des.getServiceSecretKey(), mail.getEncryptedSenderMailPassword()),email, "Forgotten Password Mail", message, null);

                String output = URLEncoder.encode("OK","UTF-8");
                
                output = des.encryptString(session.getId(),output);
                out.print(output);
            }

            database.closeConnection();
       }
    }
}
} catch (Exception ex) {}%>